package com.kiln.juxingqs.ui

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import androidx.lifecycle.Observer
import client.global.commlib.toast.toast
import com.kiln.juxingqs.BaseMiddleActivity
import com.kiln.juxingqs.R
import com.kiln.juxingqs.databinding.ActivityDepayshowBinding
import com.kiln.juxingqs.ui.vm.DePayShowViewModel


class DePayShowActivity : BaseMiddleActivity<DePayShowViewModel, ActivityDepayshowBinding>() {

    override fun getLayout(): Int {
        return R.layout.activity_depayshow
    }

    override fun initViewModel(): DePayShowViewModel = createViewModel()

    override fun initView() {
        binding?.apply {
            event = this@DePayShowActivity
            vm = viewModel

            hangm = "上海汇付支付有限公司-备付金账户"
            yinhanghao = "991290000099"
            huming = "上海汇付支付有限公司"
            zhanghao = "215500687"
            remark = intent.getStringExtra("remark")
            price = intent.getStringExtra("price")

        }
    }

    override fun observerUI() {
        viewModel.call.observe(this, Observer {
            it?.apply {
                if (isSuccess) {
                    toast("操作成功")
                    finish()
                }
            }
        })
    }

    fun fuziStr(s: String) {

        val clipboard: ClipboardManager =
            getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager

        val clip = ClipData.newPlainText("label", s)

        clipboard.setPrimaryClip(clip)
        toast("已复制")
    }

}